package com.xianxing.common.util;

import lombok.Data;

/**
 * 接口响应封装类
 * auth 李金全
 */
@Data
public class Response<T> {

    private boolean flag;//响应结果
    private String status;//响应状态码
    private String message;//响应消息
    private T data;//响应数据

    private static String success="2000";
    private static String fail="4000";

    public Response() {
    }

    private Response(boolean flag, String status, String message, T data) {
        this.flag = flag;
        this.status = status;
        this.message = message;
        this.data = data;
    }

    private Response(boolean flag, String status, String message) {
        this.flag = flag;
        this.status = status;
        this.message = message;
    }

    public static Response OK(String message){
        return new Response(true,success,message);
    }
    public static Response OK(String message,Object data){
        return new Response(true,success,message,data);
    }

    public static Response FAIL(String message){
        return new Response(false,fail,message);
    }
    public static Response FAIL(String message,Object data){
        return new Response(false,fail,message,data);
    }
}
